// This sample prints the name of the viewer and the owner of 
// the gadget to OrkutDevBox's debug console

function init() {
   var req = opensocial.newDataRequest();
   req.add(req.newFetchPersonRequest(
              opensocial.IdSpec.PersonId.VIEWER), "myviewer");
   req.add(req.newFetchPersonRequest(
              opensocial.IdSpec.PersonId.OWNER), "myowner");
   req.send(callback);
   debug.say("Request sent. Waiting for reply...");
}

function callback(data) {
   if (data.hadError()) { 
      debug.say("Error!");
      // ... further error handling here ...
      return; 
   }
   var viewer = data.get("myviewer").getData();
   var owner = data.get("myowner").getData();
   debug.say("Viewer is " + viewer.getDisplayName());
   debug.say("Owner is " + owner.getDisplayName());
}

gadgets.util.registerOnLoadHandler(init);

